package com.example.newsheadline;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.view.LayoutInflaterCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity 
{
	public static final String APPURL="http://118.244.212.82:9094/newsClient";
	private ListView lv_left; 
	private Random r = new Random();
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		lv_left = (ListView)findViewById(R.id.listView_left);
		//init datas 
		List<String> datas = new ArrayList<String>();
		for (int i = 0; i < 5; i++)
		{
			datas.add(i+"");
		}
		// set adapter arrayadapter   simpleadapter
//		lv_left.setAdapter(new SimpleAdapter(this, datas, resource, from, to));
		
	}
	class drawerAdapter extends BaseAdapter
	{
		private List<String> list;

		public drawerAdapter(List<String> list)
		{
			this.list = list;
		}
		@Override
		public int getCount()
		{
			// TODO Auto-generated method stub
			return list.size();
		}

		@Override
		public Object getItem(int position)
		{
			// TODO Auto-generated method stub
			return list.get(position);
		}

		@Override
		public long getItemId(int position)
		{
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent)
		{
			// TODO Auto-generated method stub
//			TextView tv = new TextView(convertView.getContext());
//			LayoutParams layoutParams = tv.getLayoutParams();
//			layoutParams.width = LayoutParams.MATCH_PARENT;
//			tv.setLayoutParams(layoutParams);
//			tv.setText(list.get(position));
			View view  = LayoutInflater.from(convertView.getContext()).inflate(R.layout.item_drawer, null);
//			view.setBackgroundColor(Color.rgb(r.nextInt(255)+1, r.nextInt(255)+1, r.nextInt(255)+1));
			return view;
		}
		
	}
	
}
